//
//  WNEmptyView.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/4.
//

import UIKit
import LYEmptyView
import Foundation

enum EmptyDesc: String {
    case netWork = "網路錯誤，請檢查網路"
    case serverBad = "頁面異常，請重新整理頁面"
    case common = "這裡什麼都沒有"
    case none = ""

    case discover = "抱歉！\n沒有書籍。"
    case recommend = "即將推出！\n更多好書籍。"
    case library = "您還沒有添加任何書籍\n到您的書架。"
    case rank = "抱歉！\n排行榜沒有數據。"
    case comment = "與我們分享您的閱讀體驗。"
    case search = "抱歉！\n沒有找到你想看的書。"
    case history = "您尚未查看任何書籍。\n去探索書籍吧！"
    case record = "您尚未獲得獎勵"
    case inbox = "無訊息"
}

enum EmptyImage: String {
    case netWork = "empty_netWork"
    case serverBad = "empty_serverBad"
    case common = "empty_common"
    case none = ""

    case discover = "empty_discover"
    case recommend = "empty_recommend"
    case library = "empty_library"
    case comment = "empty_comment"
    case inbox = "empty_inbox"
}

class WNEmptyView: LYEmptyView {
    
    var btnStr = "" {
        didSet {
            actionBtnFont = .wn_font(name: .bold, size: 15)
            actionBtnTitleColor = .white
            actionBtnBackGroundColor = .init(named: "red_FE95B4")
            actionBtnMargin = 32
            actionBtnWidth = 120
            actionBtnHeight = 36
            actionBtnCornerRadius = 18
            btnTitleStr = btnStr
        }
    }

    /// 文本 + 按钮
    class func wn_loadStyle(descStr: EmptyDesc = .none, imageStr: EmptyImage = .none, btnStr: String = "點擊刷新", _ contentViewY: CGFloat = UIResponder().scaleWidth(163), _ btnFrame: CGSize = CGSize(width: 160, height: 170), tapBlock: @escaping (()->())) -> LYEmptyView {
        let ev = WNEmptyView.emptyActionView(withImageStr: imageStr.rawValue, titleStr: "", detailStr: descStr.rawValue, btnTitleStr: btnStr, btnClick: tapBlock)
        ev?.contentViewY = contentViewY
        ev?.titleLabTextColor = .gray
        ev?.titleLabFont = .wn_font(name: .bold, size: 17)
        ev?.detailLabMaxLines = 3
        ev?.detailLabTextColor = .gray
        ev?.detailLabFont = .wn_font(name: .bold, size: 16)
        ev?.imageSize = btnFrame
        ev?.subViewMargin = 16
        if btnStr.count != 0 {
            ev?.actionBtnFont = .wn_font(name: .bold, size: 15)
            ev?.actionBtnTitleColor = .init(named: "red_FE95B4")
            ev?.actionBtnBackGroundColor = .white
            ev?.actionBtnMargin = 24
            ev?.actionBtnHeight = 44
            ev?.actionBtnWidth = 200
            ev?.actionBtnBorderWidth = 1
            ev?.actionBtnBorderColor = .init(named: "red_FE95B4")
            ev?.actionBtnCornerRadius = 22
        }
        return ev!
    }
}
